package com.zms.maze;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class ToggleLine extends Line implements Cloneable {

	private static final long serialVersionUID = 1L;
	
	public int togglex;
	public int toggley;
	public int state;
	
	public ToggleLine()
	{
		super();
	}
	public ToggleLine(Line line,int togglex,int toggley,int state) {
		super(line.x1,line.y1,line.x2,line.y2);
		this.togglex=togglex;
		this.toggley=toggley;
		this.state=state;
	}
	public ToggleLine(int x1,int y1,int x2,int y2) {
		super(x1,y1,x2,y2);
	}
	public void writeObject(ObjectOutputStream out) throws IOException {
		super.writeObject(out);
		out.writeInt(togglex);
		out.writeInt(toggley);
		out.writeInt(state);
	}
	public int getState()
	{
		return state;
	}
	
	public void setState(int state)
	{
		this.state=state;
	}
	
	public void swapState()
	{
		this.state=Math.abs(this.state-1);
	}
	
	public static ToggleLine readObject(ObjectInputStream in) throws IOException,ClassNotFoundException {
		return new ToggleLine(Line.readObject(in),in.readInt(),in.readInt(),in.readInt());
	}
	
	protected ToggleLine clone() 
	{
		try
		{

        ToggleLine c=new ToggleLine();
        c.togglex=this.togglex;
        c.toggley=this.toggley;
        c.state=this.state;
        return c;
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}
	
}
